<?php defined('SYSPATH') OR die('No direct script access.');

class Controller_Tools extends Controller_Base {


	public function action_index()
	{
		$this->template->set_filename('smarty3:system/tools');
	}

	public function action_clear_cache_query()
	{
		Model::instance('tools')->clean_all_cache();
		return $this->success('tools.success_clear_cache',FALSE);
	}

	public function action_recover_password_query()
	{
		$ip = $_SERVER['REMOTE_ADDR'];
		if (empty($ip) || !ip_in_subnet('127.0.0.1/24', $ip)) //本机方可修改密码
			return $this->failure('tools.failure_ip_invail');
		$password = Auth::instance()->hash_password('admin', '123456');
		Model::instance('member')->update(1, array('password' => $password));
		$this->success('tools.success_admin_password', FALSE);
	}

	public function action_create_static_folder_query()
	{
		Model::instance('tools')->create_static_folder();
		return $this->success('tools.success_create_static_folder',FALSE);
	}


}